﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using HKEA.CMS.Core.BLL.Mtbl;
using HKEA.CMS.Core.BLL.Tbl;
using HKEA.CMS.Core.Utility;
using HKEA.CMS.Core.BLL.App;
namespace HKEA.CMS.Core.Models
{
    public class M_BranchListDetail
    {
        public bool IsFromApp { get; set; }
        public int URLUID
        {
            get
            {
                if (IsFromApp)
                    return AppCustBranchUID;
                else
                    return CustBranchUID;
            }
        }

        public int AppCustBranchUID { get; set; }
        public int CustBranchUID { get; set; }

        public int AppAddressUID { get; set; }
        public int AddressUID { get; set; }

        public int InfoUID { get; set; }
        public int AppInfoUID { get; set; }

        public string BranchName_Eng { get; set; }
        public string BranchName_Chi { get; set; }
        public int NoOfEmployee
        {
            get;
            set;
        }
        public string strSpace { get { return ",&nbsp;"; } }


        private object obj = null;
        private tblContactInfo _info = null;
        private tblContactInfo GetinfoENT()
        {
            if (obj == null && !IsFromApp && InfoUID > 0)
            {
                tblContactInfo infoENT = new tblContactInfo();
                tblContactInfoBLL infoBLL = new tblContactInfoBLL();
                infoENT.ContactInfoUID = InfoUID;
                _info = infoBLL.GetEntity(infoENT);
                obj = new object();
            }
            return _info;
        }

        private object appobj = null;
        private app_tblContactInfo _appinfo = null;
        private app_tblContactInfo GetappinfoENT()
        {

            if (appobj == null && IsFromApp && AppInfoUID > 0)
            {
                app_tblContactInfo tempENT = null;
                tempENT = new app_tblContactInfo();
                app_tblContactInfoBLL infoBLL = new app_tblContactInfoBLL();
                tempENT.AppContactInfoUID = AppInfoUID;
                _appinfo = infoBLL.GetAppENTByENT(tempENT);
                appobj = new object();
            }
            return _appinfo;
        }
        public tblContactInfo InfoENT
        {
            get
            {
                return GetinfoENT();
            }
        }

        public app_tblContactInfo AppInfoENT
        {
            get
            {
                return GetappinfoENT();
            }
        }

        public mtblArea areaENT { get; set; }

        public mtblCountry countryENT { get; set; }

        public string strAddress
        {
            get
            {
                string str = string.Empty;
                StringBuilder strBuilder = new StringBuilder();
                if (!IsFromApp)
                {
                    #region 从tbl表中取数据
                    tblAddressBLL bll = new tblAddressBLL();
                    tblAddress addressENT = new tblAddress();
                    addressENT.AddressUID = AddressUID;
                    addressENT = bll.GetEntity(addressENT);
                    if (addressENT != null)
                    {
                        countryENT = addressENT.mtblCountry;
                        if (addressENT.mtblCountry != null)
                        {
                            mtblArea area = new mtblArea();
                            mtblAreaBLL areaBLL = new mtblAreaBLL();
                            area.AreaUID = (int)addressENT.mtblCountry.AreaUID;
                            area.Deleted = 0;
                            areaENT = areaBLL.GetEntity(area);
                        }


                        if (!string.IsNullOrEmpty(addressENT.Flat_Bldg_Eng))
                            strBuilder.Append(addressENT.Flat_Bldg_Eng).Append("&nbsp;");
                        if (!string.IsNullOrEmpty(addressENT.Street_Rd_Eng))
                            strBuilder.Append(addressENT.Street_Rd_Eng).Append("&nbsp;");
                        if (!string.IsNullOrEmpty(addressENT.Area_Eng))
                            strBuilder.Append(addressENT.Area_Eng).Append("&nbsp;");
                        if (!string.IsNullOrEmpty(addressENT.District_Eng))
                            strBuilder.Append(addressENT.District_Eng).Append("&nbsp;");

                        #region 英文 City、Province、Country过滤
                        if (!string.IsNullOrEmpty(addressENT.City_Eng) && !string.IsNullOrEmpty(addressENT.Province_Eng) && addressENT.City_Eng.ToLower().Trim() == addressENT.Province_Eng.ToLower().Trim())
                        {
                            strBuilder.Append(addressENT.City_Eng.Trim()).Append("&nbsp;");
                        }
                        else
                        {
                            if (!string.IsNullOrEmpty(addressENT.City_Eng))
                                strBuilder.Append(addressENT.City_Eng.Trim()).Append("&nbsp;");
                            if (!string.IsNullOrEmpty(addressENT.Province_Eng))
                                strBuilder.Append(addressENT.Province_Eng.Trim()).Append("&nbsp;");
                        }
                        if (countryENT != null)
                        {
                            string strCounrtyEng = countryENT.Country_Eng;
                            if (!string.IsNullOrEmpty(addressENT.Province_Eng) && !string.IsNullOrEmpty(strCounrtyEng) && addressENT.Province_Eng.ToLower().Trim() == strCounrtyEng.ToLower().Trim())
                            {
                            }
                            else
                            {
                                if (string.IsNullOrEmpty(addressENT.Province_Eng) && !string.IsNullOrEmpty(strCounrtyEng) && !string.IsNullOrEmpty(addressENT.City_Eng) && strCounrtyEng.ToLower().Trim() == addressENT.City_Eng.ToLower().Trim())
                                {
                                }
                                else
                                {
                                    if (!string.IsNullOrEmpty(strCounrtyEng))
                                    {
                                        strBuilder.Append(strCounrtyEng.Trim()).Append("&nbsp;");
                                    }
                                }
                            }
                        }
                        if (areaENT != null)
                        {
                            if (!string.IsNullOrEmpty(areaENT.Area_Eng))
                            {
                                strBuilder.Append(areaENT.Area_Eng.Trim()).Append("&nbsp;");
                            }
                        }
                        #endregion

                        strBuilder.Append("<br/>");

                        if (areaENT != null)
                        {
                            if (!string.IsNullOrEmpty(areaENT.Area_Chi))
                                strBuilder.Append(areaENT.Area_Chi);
                        }
                        string strCountryChi = string.Empty;
                        string CityChi = addressENT.City_Chi;
                        string ProvinceChi = addressENT.Province_Chi;
                        if (countryENT != null)
                        {
                            strCountryChi = countryENT.Country_Chi;
                        }



                        if (!string.IsNullOrEmpty(strCountryChi))
                        {
                            strBuilder.Append(strCountryChi.Trim());
                            if (!string.IsNullOrEmpty(ProvinceChi))
                            {
                                if (strCountryChi.ToLower().Trim() != ProvinceChi.ToLower().Trim())
                                {
                                    strBuilder.Append(ProvinceChi.Trim());
                                    if (!string.IsNullOrEmpty(CityChi) && CityChi.ToLower().Trim() != ProvinceChi.ToLower().Trim())
                                        strBuilder.Append(CityChi.Trim());
                                }
                            }
                            else //省份为空
                            {
                                if (!string.IsNullOrEmpty(CityChi) && CityChi.ToLower().Trim() != strCountryChi.ToLower().Trim())
                                    strBuilder.Append(CityChi.Trim());
                            }
                        }
                        else //国家为空
                        {
                            if (!string.IsNullOrEmpty(ProvinceChi))
                            {
                                strBuilder.Append(ProvinceChi.Trim());
                                if (!string.IsNullOrEmpty(CityChi) && CityChi.ToLower().Trim() != ProvinceChi.ToLower().ToLower())
                                {
                                    strBuilder.Append(CityChi.Trim());
                                }
                            }
                            else
                            {
                                if (!string.IsNullOrEmpty(CityChi))
                                    strBuilder.Append(CityChi.Trim());
                            }
                        }
                        if (!string.IsNullOrEmpty(addressENT.District_Chi))
                            strBuilder.Append(addressENT.District_Chi);
                        if (!string.IsNullOrEmpty(addressENT.Area_Chi))
                            strBuilder.Append(addressENT.Area_Chi);
                        if (!string.IsNullOrEmpty(addressENT.Street_Rd_Chi))
                            strBuilder.Append(addressENT.Street_Rd_Chi);
                        if (!string.IsNullOrEmpty(addressENT.Flat_Bldg_Chi))
                            strBuilder.Append(addressENT.Flat_Bldg_Chi);
                    }
                    #endregion
                }
                else
                {
                    #region 从 app表中取数据
                    app_tblAddress addressENT = new app_tblAddress();
                    app_tblAddressBLL bll = new app_tblAddressBLL();
                    addressENT.AppAddressUID = AppAddressUID;
                    addressENT = bll.GetAppENTByENT(addressENT);
                    if (addressENT != null)
                    {
                        countryENT = addressENT.mtblCountry;
                        if (addressENT.mtblCountry != null)
                        {
                            mtblArea area = new mtblArea();
                            mtblAreaBLL areaBLL = new mtblAreaBLL();
                            area.AreaUID = (int)addressENT.mtblCountry.AreaUID;
                            area.Deleted = 0;
                            areaENT = areaBLL.GetEntity(area);
                        }


                        if (!string.IsNullOrEmpty(addressENT.Flat_Bldg_Eng))
                            strBuilder.Append(addressENT.Flat_Bldg_Eng).Append("&nbsp;");
                        if (!string.IsNullOrEmpty(addressENT.Street_Rd_Eng))
                            strBuilder.Append(addressENT.Street_Rd_Eng).Append("&nbsp;");
                        if (!string.IsNullOrEmpty(addressENT.Area_Eng))
                            strBuilder.Append(addressENT.Area_Eng).Append("&nbsp;");
                        if (!string.IsNullOrEmpty(addressENT.District_Eng))
                            strBuilder.Append(addressENT.District_Eng).Append("&nbsp;");

                        #region 英文 City、Province、Country过滤
                        if (!string.IsNullOrEmpty(addressENT.City_Eng) && !string.IsNullOrEmpty(addressENT.Province_Eng) && addressENT.City_Eng.ToLower().Trim() == addressENT.Province_Eng.ToLower().Trim())
                        {
                            strBuilder.Append(addressENT.City_Eng.Trim()).Append("&nbsp;");
                        }
                        else
                        {
                            if (!string.IsNullOrEmpty(addressENT.City_Eng))
                                strBuilder.Append(addressENT.City_Eng.Trim()).Append("&nbsp;");
                            if (!string.IsNullOrEmpty(addressENT.Province_Eng))
                                strBuilder.Append(addressENT.Province_Eng.Trim()).Append("&nbsp;");
                        }
                        if (countryENT != null)
                        {
                            string strCounrtyEng = countryENT.Country_Eng;
                            if (!string.IsNullOrEmpty(addressENT.Province_Eng) && !string.IsNullOrEmpty(strCounrtyEng) && addressENT.Province_Eng.ToLower().Trim() == strCounrtyEng.ToLower().Trim())
                            {
                            }
                            else
                            {
                                if (string.IsNullOrEmpty(addressENT.Province_Eng) && !string.IsNullOrEmpty(strCounrtyEng) && !string.IsNullOrEmpty(addressENT.City_Eng) && strCounrtyEng.ToLower().Trim() == addressENT.City_Eng.ToLower().Trim())
                                {
                                }
                                else
                                {
                                    if (!string.IsNullOrEmpty(strCounrtyEng))
                                    {
                                        strBuilder.Append(strCounrtyEng.Trim()).Append("&nbsp;");
                                    }
                                }
                            }
                        }
                        if (areaENT != null)
                        {
                            if (!string.IsNullOrEmpty(areaENT.Area_Eng))
                            {
                                strBuilder.Append(areaENT.Area_Eng.Trim()).Append("&nbsp;");
                            }
                        }
                        #endregion

                        strBuilder.Append("<br/>");

                        if (areaENT != null)
                        {
                            if (!string.IsNullOrEmpty(areaENT.Area_Chi))
                                strBuilder.Append(areaENT.Area_Chi);
                        }
                        string strCountryChi = string.Empty;
                        string CityChi = addressENT.City_Chi;
                        string ProvinceChi = addressENT.Province_Chi;
                        if (countryENT != null)
                        {
                            strCountryChi = countryENT.Country_Chi;
                        }



                        if (!string.IsNullOrEmpty(strCountryChi))
                        {
                            strBuilder.Append(strCountryChi.Trim());
                            if (!string.IsNullOrEmpty(ProvinceChi))
                            {
                                if (strCountryChi.ToLower().Trim() != ProvinceChi.ToLower().Trim())
                                {
                                    strBuilder.Append(ProvinceChi.Trim());
                                    if (!string.IsNullOrEmpty(CityChi) && CityChi.ToLower().Trim() != ProvinceChi.ToLower().Trim())
                                        strBuilder.Append(CityChi.Trim());
                                }
                            }
                            else //省份为空
                            {
                                if (!string.IsNullOrEmpty(CityChi) && CityChi.ToLower().Trim() != strCountryChi.ToLower().Trim())
                                    strBuilder.Append(CityChi.Trim());
                            }
                        }
                        else //国家为空
                        {
                            if (!string.IsNullOrEmpty(ProvinceChi))
                            {
                                strBuilder.Append(ProvinceChi.Trim());
                                if (!string.IsNullOrEmpty(CityChi) && CityChi.ToLower().Trim() != ProvinceChi.ToLower().ToLower())
                                {
                                    strBuilder.Append(CityChi.Trim());
                                }
                            }
                            else
                            {
                                if (!string.IsNullOrEmpty(CityChi))
                                    strBuilder.Append(CityChi.Trim());
                            }
                        }
                        if (!string.IsNullOrEmpty(addressENT.District_Chi))
                            strBuilder.Append(addressENT.District_Chi);
                        if (!string.IsNullOrEmpty(addressENT.Area_Chi))
                            strBuilder.Append(addressENT.Area_Chi);
                        if (!string.IsNullOrEmpty(addressENT.Street_Rd_Chi))
                            strBuilder.Append(addressENT.Street_Rd_Chi);
                        if (!string.IsNullOrEmpty(addressENT.Flat_Bldg_Chi))
                            strBuilder.Append(addressENT.Flat_Bldg_Chi);
                    }
                    #endregion
                }
                str = strBuilder.ToString();
                return str;
            }
        }

        public string Email
        {
            get
            {
                string str = string.Empty;
                StringBuilder strBuilder = new StringBuilder();
                if (IsFromApp && AppInfoENT != null)
                {
                    if (!string.IsNullOrEmpty(AppInfoENT.Email1))
                        strBuilder.Append(AppInfoENT.Email1).Append(strSpace);
                    if (!string.IsNullOrEmpty(AppInfoENT.Email2))
                        strBuilder.Append(AppInfoENT.Email2).Append(strSpace);
                    if (!string.IsNullOrEmpty(AppInfoENT.Email3))
                        strBuilder.Append(AppInfoENT.Email3).Append(strSpace);
                    if (!string.IsNullOrEmpty(AppInfoENT.Email4))
                        strBuilder.Append(AppInfoENT.Email4).Append(strSpace);
                    if (!string.IsNullOrEmpty(AppInfoENT.Email5))
                        strBuilder.Append(AppInfoENT.Email5).Append(strSpace);
                    str = strBuilder.ToString();
                    if (str.Length > 0)
                        str = str.Substring(0, str.Length - strSpace.Length);
                }
                else
                {
                    if (InfoENT != null)
                    {
                        if (!string.IsNullOrEmpty(InfoENT.Email1))
                            strBuilder.Append(InfoENT.Email1).Append(strSpace);
                        if (!string.IsNullOrEmpty(InfoENT.Email2))
                            strBuilder.Append(InfoENT.Email2).Append(strSpace);
                        if (!string.IsNullOrEmpty(InfoENT.Email3))
                            strBuilder.Append(InfoENT.Email3).Append(strSpace);
                        if (!string.IsNullOrEmpty(InfoENT.Email4))
                            strBuilder.Append(InfoENT.Email4).Append(strSpace);
                        if (!string.IsNullOrEmpty(InfoENT.Email5))
                            strBuilder.Append(InfoENT.Email5).Append(strSpace);
                        str = strBuilder.ToString();
                        if (str.Length > 0)
                            str = str.Substring(0, str.Length - strSpace.Length);
                    }
                }
                return str;
            }
        }

        public string WebSite
        {
            get
            {
                string str = string.Empty;
                StringBuilder strBuilder = new StringBuilder();
                if (IsFromApp && AppInfoENT != null)
                {
                    if (!string.IsNullOrEmpty(AppInfoENT.Website1))
                        strBuilder.Append(AppInfoENT.Website1).Append(strSpace);
                    if (!string.IsNullOrEmpty(AppInfoENT.Website2))
                        strBuilder.Append(AppInfoENT.Website2).Append(strSpace);
                    str = strBuilder.ToString();
                    if (str.Length > 0)
                        str = str.Substring(0, str.Length - strSpace.Length);
                }
                else if (InfoENT != null)
                {
                    if (!string.IsNullOrEmpty(InfoENT.Website1))
                        strBuilder.Append(InfoENT.Website1).Append(strSpace);
                    if (!string.IsNullOrEmpty(InfoENT.Website2))
                        strBuilder.Append(InfoENT.Website2).Append(strSpace);
                    str = strBuilder.ToString();
                    if (str.Length > 0)
                        str = str.Substring(0, str.Length - strSpace.Length);
                }
                return str;
            }
        }

        public string strTel
        {
            get
            {
                string str = string.Empty;
                StringBuilder strBuilder = new StringBuilder();
                if (IsFromApp && AppInfoENT != null)
                {
                    #region
                    if (!string.IsNullOrEmpty(AppInfoENT.Tel1))
                    {
                        if (!string.IsNullOrEmpty(AppInfoENT.Tel1_AreaCode))
                            strBuilder.Append("(").Append(AppInfoENT.Tel1_AreaCode).Append(") ");
                        if (!string.IsNullOrEmpty(AppInfoENT.Tel1_CountryCode))
                            strBuilder.Append("(").Append(AppInfoENT.Tel1_CountryCode).Append(") ");
                        strBuilder.Append(AppInfoENT.Tel1).Append(strSpace);
                    }
                    if (!string.IsNullOrEmpty(AppInfoENT.Tel2))
                    {
                        if (!string.IsNullOrEmpty(AppInfoENT.Tel2_AreaCode))
                            strBuilder.Append("(").Append(AppInfoENT.Tel2_AreaCode).Append(") ");
                        if (!string.IsNullOrEmpty(AppInfoENT.Tel2_CountryCode))
                            strBuilder.Append("(").Append(AppInfoENT.Tel2_CountryCode).Append(") ");
                        strBuilder.Append(AppInfoENT.Tel2).Append(strSpace);
                    }
                    if (!string.IsNullOrEmpty(AppInfoENT.Tel3))
                    {
                        if (!string.IsNullOrEmpty(AppInfoENT.Tel3_AreaCode))
                            strBuilder.Append("(").Append(AppInfoENT.Tel3_AreaCode).Append(") ");
                        if (!string.IsNullOrEmpty(AppInfoENT.Tel3_CountryCode))
                            strBuilder.Append("(").Append(AppInfoENT.Tel3_CountryCode).Append(") ");
                        strBuilder.Append(AppInfoENT.Tel3).Append(strSpace);
                    }
                    if (!string.IsNullOrEmpty(AppInfoENT.Tel4))
                    {
                        if (!string.IsNullOrEmpty(AppInfoENT.Tel4_AreaCode))
                            strBuilder.Append("(").Append(AppInfoENT.Tel4_AreaCode).Append(") ");
                        if (!string.IsNullOrEmpty(AppInfoENT.Tel4_CountryCode))
                            strBuilder.Append("(").Append(AppInfoENT.Tel4_CountryCode).Append(") ");
                        strBuilder.Append(AppInfoENT.Tel4).Append(strSpace);
                    }
                    if (!string.IsNullOrEmpty(AppInfoENT.Tel5))
                    {
                        if (!string.IsNullOrEmpty(AppInfoENT.Tel5_AreaCode))
                            strBuilder.Append("(").Append(AppInfoENT.Tel5_AreaCode).Append(") ");
                        if (!string.IsNullOrEmpty(AppInfoENT.Tel5_CountryCode))
                            strBuilder.Append("(").Append(AppInfoENT.Tel5_CountryCode).Append(") ");
                        strBuilder.Append(AppInfoENT.Tel5).Append(strSpace);
                    }
                    #endregion
                }
                else if (InfoENT != null)
                {
                    #region
                    if (!string.IsNullOrEmpty(InfoENT.Tel1))
                    {
                        if (!string.IsNullOrEmpty(InfoENT.Tel1_AreaCode))
                            strBuilder.Append("(").Append(InfoENT.Tel1_AreaCode).Append(") ");
                        if (!string.IsNullOrEmpty(InfoENT.Tel1_CountryCode))
                            strBuilder.Append("(").Append(InfoENT.Tel1_CountryCode).Append(") ");
                        strBuilder.Append(InfoENT.Tel1).Append(strSpace);
                    }
                    if (!string.IsNullOrEmpty(InfoENT.Tel2))
                    {
                        if (!string.IsNullOrEmpty(InfoENT.Tel2_AreaCode))
                            strBuilder.Append("(").Append(InfoENT.Tel2_AreaCode).Append(") ");
                        if (!string.IsNullOrEmpty(InfoENT.Tel2_CountryCode))
                            strBuilder.Append("(").Append(InfoENT.Tel2_CountryCode).Append(") ");
                        strBuilder.Append(InfoENT.Tel2).Append(strSpace);
                    }
                    if (!string.IsNullOrEmpty(InfoENT.Tel3))
                    {
                        if (!string.IsNullOrEmpty(InfoENT.Tel3_AreaCode))
                            strBuilder.Append("(").Append(InfoENT.Tel3_AreaCode).Append(") ");
                        if (!string.IsNullOrEmpty(InfoENT.Tel3_CountryCode))
                            strBuilder.Append("(").Append(InfoENT.Tel3_CountryCode).Append(") ");
                        strBuilder.Append(InfoENT.Tel3).Append(strSpace);
                    }
                    if (!string.IsNullOrEmpty(InfoENT.Tel4))
                    {
                        if (!string.IsNullOrEmpty(InfoENT.Tel4_AreaCode))
                            strBuilder.Append("(").Append(InfoENT.Tel4_AreaCode).Append(") ");
                        if (!string.IsNullOrEmpty(InfoENT.Tel4_CountryCode))
                            strBuilder.Append("(").Append(InfoENT.Tel4_CountryCode).Append(") ");
                        strBuilder.Append(InfoENT.Tel4).Append(strSpace);
                    }
                    if (!string.IsNullOrEmpty(InfoENT.Tel5))
                    {
                        if (!string.IsNullOrEmpty(InfoENT.Tel5_AreaCode))
                            strBuilder.Append("(").Append(InfoENT.Tel5_AreaCode).Append(") ");
                        if (!string.IsNullOrEmpty(InfoENT.Tel5_CountryCode))
                            strBuilder.Append("(").Append(InfoENT.Tel5_CountryCode).Append(") ");
                        strBuilder.Append(InfoENT.Tel5).Append(strSpace);
                    }
                    #endregion
                }
                str = strBuilder.ToString();
                if (str.Length > 0)
                    str = str.Substring(0, str.Length - strSpace.Length);
                return str;
            }
        }

        public string strFax
        {
            get
            {
                string str = string.Empty;
                StringBuilder strBuilder = new StringBuilder();
                if (IsFromApp && AppInfoENT != null)
                {
                    #region
                    if (!string.IsNullOrEmpty(AppInfoENT.Fax1))
                    {
                        if (!string.IsNullOrEmpty(AppInfoENT.Fax1_AreaCode))
                            strBuilder.Append("(").Append(AppInfoENT.Fax1_AreaCode).Append(") ");
                        if (!string.IsNullOrEmpty(AppInfoENT.Fax1_CountryCode))
                            strBuilder.Append("(").Append(AppInfoENT.Fax1_CountryCode).Append(") ");
                        strBuilder.Append(AppInfoENT.Fax1).Append(strSpace);
                    }
                    if (!string.IsNullOrEmpty(AppInfoENT.Fax2))
                    {
                        if (!string.IsNullOrEmpty(AppInfoENT.Fax2_AreaCode))
                            strBuilder.Append("(").Append(AppInfoENT.Fax2_AreaCode).Append(") ");
                        if (!string.IsNullOrEmpty(AppInfoENT.Fax2_CountryCode))
                            strBuilder.Append("(").Append(AppInfoENT.Fax2_CountryCode).Append(") ");
                        strBuilder.Append(AppInfoENT.Fax2).Append(strSpace);
                    }
                    if (!string.IsNullOrEmpty(AppInfoENT.Fax3))
                    {
                        if (!string.IsNullOrEmpty(AppInfoENT.Fax3_AreaCode))
                            strBuilder.Append("(").Append(AppInfoENT.Fax3_AreaCode).Append(") ");
                        if (!string.IsNullOrEmpty(AppInfoENT.Fax3_CountryCode))
                            strBuilder.Append("(").Append(AppInfoENT.Fax3_CountryCode).Append(") ");
                        strBuilder.Append(AppInfoENT.Fax3).Append(strSpace);
                    }
                    if (!string.IsNullOrEmpty(AppInfoENT.Fax4))
                    {
                        if (!string.IsNullOrEmpty(AppInfoENT.Fax4_AreaCode))
                            strBuilder.Append("(").Append(AppInfoENT.Fax4_AreaCode).Append(") ");
                        if (!string.IsNullOrEmpty(AppInfoENT.Fax4_CountryCode))
                            strBuilder.Append("(").Append(AppInfoENT.Fax4_CountryCode).Append(") ");
                        strBuilder.Append(AppInfoENT.Fax4).Append(strSpace);
                    }
                    if (!string.IsNullOrEmpty(AppInfoENT.Fax5))
                    {
                        if (!string.IsNullOrEmpty(AppInfoENT.Fax5_AreaCode))
                            strBuilder.Append("(").Append(AppInfoENT.Fax5_AreaCode).Append(") ");
                        if (!string.IsNullOrEmpty(AppInfoENT.Fax5_CountryCode))
                            strBuilder.Append("(").Append(AppInfoENT.Fax5_CountryCode).Append(") ");
                        strBuilder.Append(AppInfoENT.Fax5).Append(strSpace);
                    }
                    #endregion
                }
                else if (InfoENT != null)
                {
                    #region
                    if (!string.IsNullOrEmpty(InfoENT.Fax1))
                    {
                        if (!string.IsNullOrEmpty(InfoENT.Fax1_AreaCode))
                            strBuilder.Append("(").Append(InfoENT.Fax1_AreaCode).Append(") ");
                        if (!string.IsNullOrEmpty(InfoENT.Fax1_CountryCode))
                            strBuilder.Append("(").Append(InfoENT.Fax1_CountryCode).Append(") ");
                        strBuilder.Append(InfoENT.Fax1).Append(strSpace);
                    }
                    if (!string.IsNullOrEmpty(InfoENT.Fax2))
                    {
                        if (!string.IsNullOrEmpty(InfoENT.Fax2_AreaCode))
                            strBuilder.Append("(").Append(InfoENT.Fax2_AreaCode).Append(") ");
                        if (!string.IsNullOrEmpty(InfoENT.Fax2_CountryCode))
                            strBuilder.Append("(").Append(InfoENT.Fax2_CountryCode).Append(") ");
                        strBuilder.Append(InfoENT.Fax2).Append(strSpace);
                    }
                    if (!string.IsNullOrEmpty(InfoENT.Fax3))
                    {
                        if (!string.IsNullOrEmpty(InfoENT.Fax3_AreaCode))
                            strBuilder.Append("(").Append(InfoENT.Fax3_AreaCode).Append(") ");
                        if (!string.IsNullOrEmpty(InfoENT.Fax3_CountryCode))
                            strBuilder.Append("(").Append(InfoENT.Fax3_CountryCode).Append(") ");
                        strBuilder.Append(InfoENT.Fax3).Append(strSpace);
                    }
                    if (!string.IsNullOrEmpty(InfoENT.Fax4))
                    {
                        if (!string.IsNullOrEmpty(InfoENT.Fax4_AreaCode))
                            strBuilder.Append("(").Append(InfoENT.Fax4_AreaCode).Append(") ");
                        if (!string.IsNullOrEmpty(InfoENT.Fax4_CountryCode))
                            strBuilder.Append("(").Append(InfoENT.Fax4_CountryCode).Append(") ");
                        strBuilder.Append(InfoENT.Fax4).Append(strSpace);
                    }
                    if (!string.IsNullOrEmpty(InfoENT.Fax5))
                    {
                        if (!string.IsNullOrEmpty(InfoENT.Fax5_AreaCode))
                            strBuilder.Append("(").Append(InfoENT.Fax5_AreaCode).Append(") ");
                        if (!string.IsNullOrEmpty(InfoENT.Fax5_CountryCode))
                            strBuilder.Append("(").Append(InfoENT.Fax5_CountryCode).Append(") ");
                        strBuilder.Append(InfoENT.Fax5).Append(strSpace);
                    }
                    #endregion
                }
                str = strBuilder.ToString();
                if (str.Length > 0)
                    str = str.Substring(0, str.Length - strSpace.Length);
                return str;
            }
        }

        public string FullName
        {
            get
            {
                string str = string.Empty;
                str += BranchName_Eng;
                if (!string.IsNullOrEmpty(BranchName_Chi) && !string.IsNullOrEmpty(BranchName_Eng))
                { str += "&nbsp;"; }
                str += BranchName_Chi;
                return str;
            }
        }

        public string FullNameAndImg
        {
            get
            {
                string str = string.Empty;
                string strImgUrl = string.Empty;
                if (IsFromApp)
                {
                    app_tblMediaRoom_Related app_related = new app_tblMediaRoom_Related();
                    app_tblMediaRoom_RelatedBLL app_relatedBLL = new app_tblMediaRoom_RelatedBLL();
                    app_related.Category = Constant.MediaRoomCategory.branch_image;
                    app_related.AppRelatedUID = AppCustBranchUID;
                    app_related.Deleted = 0;

                    var tempList = app_relatedBLL.GetListByENT(app_related);
                    if (tempList != null && tempList.Where(a => a.Deleted == 0).ToList().Count > 0)
                    {
                        strImgUrl = "<img src=\"/Media/Css/images/cphsmedia.png\" />";
                    }
                }
                tblMediaRoomRelatedBLL relatedBLL = new tblMediaRoomRelatedBLL();
                tblMediaRoom_Related related = new tblMediaRoom_Related();
                related.Category = Constant.MediaRoomCategory.branch_image;
                related.RelatedUID = CustBranchUID;
                related.Deleted = 0;
                if (relatedBLL.GetEntity(related) != null)
                {
                    strImgUrl = "<img src=\"/Media/Css/images/cphsmedia.png\" />";
                }
                str = string.Format("{0} {1}", FullName, strImgUrl);

                return str;
            }
        }
    }
}
